import { Component } from 'react'
import classnames from 'classnames';
import Taro from '@tarojs/taro'
import IQRequest from '@common/iq-request/request'

export interface BaseProps<T = {}> {
    /**
     * 自定义class
     */
    className?: string;
    /**
     * 自定义样式
     */
    style?: React.CSSProperties;
    action?: {};
    state?: T;
    children?: any;
}

export interface BaseState {
    loading?: boolean;
}
type ClassValue = string | number | undefined | null | boolean | { [key: string]: boolean };

export class BaseComponent<TProps = {}, TState = {}, TStore = {}> extends Component<
    BaseProps<TStore> & TProps,
    TState & BaseState
> {
    constructor(props) {
        super(props);
    }


    classNames(...args: ClassValue[]) {
        return classnames(args);
    }

    className(...args: ClassValue[]) {
        return this.classNames(...args.concat([this.props.className]));
    }

    Toast(title, icon, duration = 3000) {
        Taro.showToast({
            title: title,
            icon: icon || 'loading',
            duration: duration
        })
    }

    wxShareCount = (options) => {
        IQRequest.VIVORequest(options.url, options.params).then((res: any) => { })
    }
}
